<!-- 报告存档 -->
<template>
  <div>
    <card :bordered="false">
      <p slot=title>报告存档</p>
      <table class="reportArchives" width='100%' border="1" cellspacing="0" cellpadding="0" ref="print">
        <tr>
          <th colspan="4">报告存档表</th>
        </tr>
        <tr>
          <td width="25%">项目编号</td>
          <td colspan="3">
            {{info.Project_number}}
          </td>
        </tr>
        <tr>
          <td width="25%">项目名称</td>
          <td colspan="3">
            <Input v-model="info.Project_name" />
          </td>
        </tr>
        <tr>
          <td width="25%">建设单位</td>
          <td colspan="3">
            <Input v-model="info.Build_unit" />
          </td>
        </tr>
        <tr>
          <td width="25%">建设地点</td>
          <td colspan="3">
            <Input v-model="info.Build_address" />
          </td>
        </tr>

        <tr>
          <td width="25%">报告类型</td>
          <td colspan="3">
            <Input v-model="info.Report_type" />
          </td>
        </tr>
        <tr>
          <td width="25%">项目负责人</td>
          <td width="25%">
            {{info.Perject_leader}}
          </td>
          <td width="25%">项目组其他成员</td>
          <td>
            {{cyz}}
          </td>
        </tr>
        <tr>
          <td width="25%">审批部门</td>
          <td></td>
          <td>踏勘时间</td>
          <td>
            {{this.$moment().format('YYYY-MM-DD')}}
          </td>
        </tr>
        <tr>
          <td width="25%">送审时间</td>
          <td>
            {{this.$moment().format('YYYY-MM-DD')}}
          </td>
          <td>报批时间</td>
          <td>
            {{this.$moment().format('YYYY-MM-DD')}}
          </td>
        </tr>
      </table>
      <table v-if="!loading" class="cdzl" width='100%' border="1" cellspacing="0" cellpadding="0" style="margin: 10px 0 ">
        <tr>
          <th colspan="5">存档资料清单</th>
        </tr>
        <tr>
          <th width="3%">序号</th>
          <th colspan="2">名称</th>
          <th>文件</th>
          <th>纸质存档数</th>
        </tr>
        <tr>
          <td width="3%">1</td>
          <td colspan="2">项目合同</td>
          <td>
            <Input v-model="bigs[0].A.Url" />
          </td>
          <td>
            <Input v-model="bigs[0].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">2</td>
          <td colspan="2">项目委托书</td>
          <td>
            <Input v-model="bigs[1].A.Url" />
          </td>
          <td>
            <Input v-model="bigs[1].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">3</td>
          <td colspan="2">现场踏勘表</td>
          <td>
            <Input v-model="bigs[2].A.Url" />
          </td>
          <td>
            <Input v-model="bigs[2].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">4</td>
          <td colspan="2">项目周围现状图</td>
          <td>
            <Input v-model="bigs[3].A.Url" />
          </td>
          <td>
            <Input v-model="bigs[3].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">5</td>
          <td colspan="2">三级审核</td>
          <td>
            <Input v-model="bigs[4].A.Url" />
          </td>
          <td>
            <Input v-model="bigs[4].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">6</td>
          <td colspan="2">
            <Icon type="ios-medical" color="#ff6868" />
            项目批复或审批文件
          </td>
          <td>
            <Upload action="//jsonplaceholder.typicode.com/posts/">
              <Button>上传</Button>
            </Upload>
          </td>
          <td>
            <Input v-model="bigs[5].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">7</td>
          <td colspan="2">评估意见、签字表（原件或复印件）</td>
          <td>
            <Input v-model="bigs[6].A.Url" />
          </td>
          <td>
            <Input v-model="bigs[6].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">8</td>
          <td colspan="2">环评执行标准文件（原件或复印件）</td>
          <td>
            <Input v-model="bigs[7].A.Url" />
          </td>
          <td>
            <Input v-model="bigs[7].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">9</td>
          <td colspan="2">环境监测报告原件</td>
          <td>
            <Input v-model="bigs[8].A.Url" />
          </td>
          <td>
            <Input v-model="bigs[8].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%" rowspan="8">10</td>
          <td rowspan="8" width="5%">公参相关</td>
          <td width="29%">建设单位公用参与承诺函（原件）</td>
          <td width="30%">
            <Upload action="//jsonplaceholder.typicode.com/posts/">
              <Button>上传</Button>
            </Upload>
          </td>
          <td>
            <Input v-model="bigs[9].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">两次公示（建设单位用章）网上公示截图及网址</td>
          <td>
            <Upload action="//jsonplaceholder.typicode.com/posts/">
              <Button>上传</Button>
            </Upload>
          </td>
          <td>
            <Input v-model="bigs[10].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">公众参与调查表</td>
          <td>
            <Upload action="//jsonplaceholder.typicode.com/posts/">
              <Button>上传</Button>
            </Upload>
          </td>
          <td>
            <Input v-model="bigs[11].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">公参提交意见的原始文件</td>
          <td>
            <Upload action="//jsonplaceholder.typicode.com/posts/">
              <Button>上传</Button>
            </Upload>
          </td>
          <td>
            <Input v-model="bigs[12].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">公众参与专题报告（建设单位盖章）</td>
          <td>
            <Upload action="//jsonplaceholder.typicode.com/posts/">
              <Button>上传</Button>
            </Upload>
          </td>
          <td>
            <Input v-model="bigs[13].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">听证会相关资料</td>
          <td>
            <Upload action="//jsonplaceholder.typicode.com/posts/">
              <Button>上传</Button>
            </Upload>
          </td>
          <td>
            <Input v-model="bigs[14].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">座谈会相关资料</td>
          <td>
            <Upload action="//jsonplaceholder.typicode.com/posts/">
              <Button>上传</Button>
            </Upload>
          </td>
          <td>
            <Input v-model="bigs[15].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">或建设单位公参单行本</td>
          <td>
            <Upload action="//jsonplaceholder.typicode.com/posts/">
              <Button>上传</Button>
            </Upload>
          </td>
          <td>
            <Input v-model="bigs[16].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">11</td>
          <td colspan="2">送审版报告</td>
          <td>
            <Input v-model="bigs[17].A.Url" />
          </td>
          <td>
            <Input v-model="bigs[17].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">12</td>
          <td colspan="2">报批版报告</td>
          <td>
            <Input v-model="bigs[18].A.Url" />
          </td>
          <td>
            <Input v-model="bigs[18].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">13</td>
          <td colspan="2">建设单位提供的其他报告</td>
          <td>
            <Upload action="//jsonplaceholder.typicode.com/posts/">
              <Button>上传</Button>
            </Upload>
          </td>
          <td>
            <Input v-model="bigs[19].B.Data_stock" />
          </td>
        </tr>
        <tr>
          <td width="3%">14</td>
          <td colspan="2">
            <Icon type="ios-medical" color="#ff6868" />
            纸质资料存档位置
          </td>
          <td>
            <Input v-model="bigs[20].A.Url" />
          </td>
          <td>
            <Input v-model="bigs[20].B.Data_stock" />
          </td>
        </tr>
      </table>
      <table class="dayj" v-if="!loading" width='100%' border="1" cellspacing="0" cellpadding="0">
        <tr>
          <td width="25%">档案员意见</td>
          <td>
            <Input v-model="data1[0].Archivists_opinion" />
          </td>
        </tr>
      </table>
      <Row type="flex" justify="space-between" class="topmargin">
        <Col span="4">
        <PrintButton v-if="flag" Url="print/printArchives" :Project_id="info.Id"></PrintButton>
        </Col>
        <Col span="4">
        <div style="float: right">
          <Button type="primary" @click="submit('save')">保存</Button>
          <Button type="primary" @click="submit('submit')">提交</Button>
        </div>
        </Col>
      </Row>
      <StepBar :status="9" />

    </card>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        flag: false,
        info: {},
        cyz: "",
        bigs: {},
        data1: {},
        loading: true
      };
    },
    mounted() {
      let query = this.$route.query;
      this.query = query;
      this.getProject(this.query.id);
      // 项目成员组
      this.findStaffs();
      // 资料表
      this.showAll(this.query.Project_id || this.query.id);
    },
    methods: {
      showAll(Project_id) {
        axios
          .get("/projectArchive/showAll", {
            params: {
              Project_id
            }
          })
          .then(res => {
            if (res._STATUS == 1) {
              this.bigs = res.bigs;
              this.data1 = res.data1;
              this.data1[0].Archivists_opinion = "";
              this.loading = false;
            }
          });
      },
      /* 获取当前创建项目 */
      getProject(id) {
        axios
          .get("/projectInformation/findProjectByID", {
            params: {
              id: id || this.$route.query.Project_id
            }
          })
          .then(res => {
            this.info = res.info;
            localStorage.projectType = this.info.Perject_type;
            this.flag = true
          })
          .catch(err => {
            alert("请求崩溃1231");
          });
      },
      findStaffs() {
        axios
          .get("/audit/findStaffs", {
            params: {
              Project_id: this.query.id || this.query.Project_id
            }
          })
          .then(res => {
            if (res._STATUS == 1) {
              let cyz = [];
              res.data.forEach((e, i) => {
                cyz.push(e["Staffs_name"]);
              });
              this.cyz = cyz.join(",");
            }
          });
      },
      projectArchiveSaveAllFn() {
        let bigs = this.bigs
        let data1 = this.data1
        axios.post('/projectArchive/SaveAll', {
          Project_id: data1[0].id,
          Archivists_opinion: data1[0].Archivists_opinion,
          bigs
        }).then(res => {
          console.log(res)
        }).catch(err => {
          alert('提交失败')
        })
      },
      // 保存 save / 提交 submit
      submit(type) {
        let info = this.info;
        info.btn_way = type == "save" ? 1 : 2;
        info.Perject_type = type == "save" ? 15 : 15;
        this.projectArchiveSaveAllFn();
        axios.post('/projectInformation/saveOrUpdateProject', info).then((res) => {
          if (res._STATUS == 1) {
            let title = res._MESSAGE
            if (type == 'save') {
              this.$Modal.success({
                title,
              })
            } else {
              this.$router.push({
                name: "myProjectStock",
              })
            }
          } else {
            // 提示
            this.$Modal.error({
              title,
            })
          }
        }).catch(err => {
          alert('炸了')
        })
      }
    }
  };
</script>


<style lang="less">
  .dayj,
  .cdzl,
  .reportArchives {
    .ivu-input {
      border: none !important;
      text-align: center;
      height: 30px;

      input {
        outline: medium;
      }
    }
  }
</style>